<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="productCode" value="${param.orderCode}"></c:set>
	 	<div class="easyui-tabs"  data-options="tools:'#tab-tools',plain:true,region:'center',title:'',border:false" style="margin-top: 20px;" >
            <div  title="订单状态及明细" >
               <table   border="0" cellspacing="0" cellpadding="0" style="margin: 10px;border-top: 1px solid #ddd;">
                      <tr>
                        <td class="table_td">订单编号</td>
                        <td class="juleft">
                      		<p id="d_orderCode"></p>
                        </td>
                        <td class="table_td">订单状态</td>
                        <td class="juleft"  >
                        	<p id="d_status"></p>
                        </td>
                      </tr>
                      <tr>
                        <td class="table_td">确认金额</td>
                        <td class="juleft" id="d_confirmMoney">
                        </td>
                        <td class="table_td">订单日期</td>
                        <td class="juleft" id="d_createDate"></td>
                      </tr>
              </table>
        	 
               <table id="orderDetailTable">  </table>
        	</div>
            <div  title="订单收货信息" >
            	<table   border="0" cellspacing="0" cellpadding="0" style="margin: 10px;border-top: 1px solid #ddd;">
                      <tr>
                        <td class="table_td">收货地址</td>
                        <td class="juleft">
                      		<p id="d_address"></p>
                        </td>
                      </tr>
                      <tr>
                        <td class="table_td">收货联系人</td>
                        <td class="juleft"  >
                        	<p id="d_consignee"></p>
                        </td>
                      </tr>
                      <tr>
                        <td class="table_td">收货人联系电话</td>
                        <td class="juleft" id="d_phone">
                       	
                        </td>
                      </tr>
              </table>
        	</div>
            <div  title="订单开票信息" >
            	<table   border="0" cellspacing="0" cellpadding="0" style="margin: 10px;border-top: 1px solid #ddd;">
                       <tr>
                        <td class="table_td">开票开户银行</td>
                        <td class="juleft" id="d_invbankname"> </td>
                      </tr>
                      <tr>
                        <td class="table_td">开票电话</td>
                        <td class="juleft" > </td>
                      </tr>
                      <tr>
                        <td class="table_td">开票开户账号</td>
                        <td class="juleft" id="d_invaccno"></td>
                      </tr>
                      <tr>
                        <td class="table_td">开票税号</td>
                        <td class="juleft" id="d_invtaxno"></td>
                      </tr>
                      <tr>
                        <td class="table_td">开票单位</td>
                        <td class="juleft" id="d_invaddress"></td>
                      </tr>
                      <tr>
                        <td class="table_td">开票地址</td>
                        <td class="juleft" id="d_invcustomname"> </td>
                      </tr>
              </table>
        	</div>
       </div>
	 	  
	 	  
      
       
<script>
var orderDetailTable;
$(function(){

    orderDetailTable=$('#orderDetailTable').pDataGrid({
		 columns:[[
	          	  {field:'productCode',title:'编码',align:'center',sortable:true,width:150},
	              {field:'chsName',title:'品名',align:'center',sortable:true,width:200},
	              {field:'productSpec',title:'规格',align:'center',sortable:true,width:100},
	              {field:'producingName',title:'生产厂家',align:'center',sortable:true,width:200},
	              {field:'authorizeNumber',title:'批准文号',align:'center',sortable:true,width:160},
	              {field:'priceUseType',title:'价格类型',align:'center',sortable:true,width:100},
	              {field:'salePrice',title:'价格',align:'center',sortable:true,width:100},
	              {field:'batchNumber',title:'批号',align:'center',sortable:true,width:100},
	              {field:'validDate',title:'效期(月)',align:'center',sortable:true,width:150,
                      formatter:function(value,row,index){
                          if(value==undefined){
                              return "";
                          }
                          var unixTimestamp = new Date(value);
                          var d=unixTimestamp.getFullYear()+"-"+unixTimestamp.getMonth()+"-"+unixTimestamp.getDay();
                          return d;
                      }
                  },
	              {field:'confirmAmount',title:'数量',align:'center',sortable:true,width:100},
	              {field:'confirmMoney',title:'汇总(元)',align:'center',sortable:true,width:100}/* ,
                  {field:'action',title:'操作',align:'center',sortable:true,width:150,formatter:function(value,row){
                     return '<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="deleteCart(\''+row.orderConfirmItemId+'\')">删除</a>';
                  }} */
		          ]],
		    url:'<c:url value="/trade/getOrderDetail.s"/>',
		    pagination:false,
		    collapsible:true,
            rownumbers:true,
            fitColumns:true,
            selectOnCheck:true,
            autoRowHeight:true,
		    queryParams:{"orderCode":'<c:out value="${productCode}" />'},
			completeCallback:function(data){
				if(data.code == "100"){
					layer.msg(data.result);
				}
				else{
					$("#d_orderCode").html(data.data.emSOrder.orderCode);
					$("#d_status").html(data.data.emSOrder.strStatus);
					$("#d_confirmMoney").html(data.data.emSOrder.confirmMoney);
					$("#d_createDate").html(data.data.emSOrder.createDateStr);

					
				 	$("#d_address").html(data.data.emSOrderAddress.address);
				 	$("#d_consignee").text(data.data.emSOrderAddress.consignee);
				 	$("#d_phone").text(data.data.emSOrderAddress.phone);

				 	$("#d_invbankname").text(data.data.emCBuyer.invbankname);
				 	$("#d_invaccno").text(data.data.emCBuyer.invaccno);
				 	$("#d_invtaxno").text(data.data.emCBuyer.invtaxno);
				 	$("#d_invaddress").text(data.data.emCBuyer.invaddress);
				 	$("#d_invcustomname").text(data.data.emCBuyer.invcustomname);
				}
			}
			 
	}); 
});

function deleteCart(id){
    $.messager.confirm('确认', '您确定需要删除该条记录吗？', function(r) {
        if(r){
            var param = {"orderConfirmItemId":id,"isInvoice":'<c:out value="${param.isInvoice}"/>'};
            $.pmsAjax({
                url:'<c:url value="/trade/item/deleteEmSOrderConfirmItem.s"/>',
                data:param,
                success:function(data){
                    if(data.code=="200"){
                        layer.msg("删除成功",1, {type:1,shade: [0.2, '#ccc']});
                        $("#d_confirmMoney").html(data.data.money);
                        orderDetailTable.refresh();
                    }else if(data.code=="300"){
                        layer.msg("订单删除成功",1, {type:1,shade: [0.2, '#ccc']});
                        setTimeout(function(){location.href='<c:url value="/views/jsp/center/trade/order/c_order_list.jsp" />';},1000);
                    }else{
                        layer.msg(data.result,1, {type:8,shade: [0.2, '#ccc']});
                    }
                }
            });
        }
    });
}


</script>